
#ifndef NOSAL_EXEC_INTERNAL_FILESYSTEM_H_
#define NOSAL_EXEC_INTERNAL_FILESYSTEM_H_

#include <string>
#include <vector>

namespace netaos {
namespace nosal {
namespace exec {
namespace internal {

class Filesystem
{
public:
    /// @brief Path separator used by this class to parse and create paths.
    static const std::string PATH_SEPNOSALTOR;

    /// @brief Gets the list of subdirectories at the path specified as parameter.
    ///
    /// @param path A path to a directory containing directories.
    /// @returns A vector of strings containing the subdirectories.
    /// @throws FilesystemException in case of error.
    static std::vector<std::string> GetSubdirectories(const std::string& path);

    /// @brief Gets the list of files at the path specified as parameter.
    ///
    /// @param path A path to a directory containing files.
    /// @returns A vector of strings containing the file names of the files available at the given path.
    /// @throws FilesystemException in case of error.
    static std::vector<std::string> GetFiles(const std::string& path);

    /// @brief Gets the list of files at the path specified as parameter starting with the given prefix.
    ///
    /// @param path   A path to a directory containing files.
    /// @param prefix A prefix of names of the files for filtering.
    /// @returns A vector of strings containing the file names of the files available at the given path
    /// and starting with the given prefix.
    /// @throws FilesystemException in case of error.
    static std::vector<std::string> GetFilesStartingWith(const std::string& path, const std::string& prefix);

    /// @brief Builds the path string.
    ///
    /// @param base       A base path.
    /// @param additional A concatenating path.
    /// @returns A string containing the path.
    static std::string BuildPath(const std::string& base, const std::string& additional);

    /// @brief Extracts the file name from the given path.
    ///
    /// @param path A path to a directory or file.
    /// @returns A string containing both the directory or file name.
    static std::string ExtractFileName(const std::string& path);
};

}  // namespace internal
}  // namespace exec
}  // namespace nosal
}  // namespace netaos

#endif  // NOSAL_EXEC_INTERNAL_FILESYSTEM_H_
